<%@page import="Entity.PageBean"%>
<%@page import="JavaServlet.TimeServlet.Banji"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
<form action="${pageContext.request.contextPath}/banji?method=searchName" method="post">
		名字：<input type="text" name="searchName"/>
		<input type="submit" value="搜索"/>
	</form>
	<a href="${pageContext.request.contextPath}/banji_insert.jsp" class="btn btn-success">添加</a>
	<%-- ${list} --%>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<td>ID</td>
			<td>姓名</td>
			<td>删除</td>
			<td>修改</td>
		</tr>
		<c:forEach items="${pageBean.list}" var="banji">
			<tr>
				<td>${banji.id}</td>
				<td>${banji.name}</td>
				<td><a href="/JavaWeb190703/banjiDelete?id=${banji.id}">删除</a></td>
				<td><a href="${pageContext.request.contextPath}/banji?method=toUpdate&id=${banji.id}">修改</a></td>
			</tr>
		</c:forEach>
		</table>
	<nav aria-label="Page navigation">
	  <ul class="pagination">
	  <c:if test="${pageBean.pageNo==1}">  
	  	 <li class="disabled">
	      <a href="#" aria-label="Previous">
	        <span aria-hidden="true">&laquo;</span>
	      </a>
	    </li>
	  </c:if>
	  <c:if test="${pageBean.pageNo!=1}">
	    <li>
	      <a href="${pageContext.request.contextPath}/banji?method=pageList&pageNo=${pageBean.pageNo-1}" aria-label="Previous">
	        <span aria-hidden="true">&laquo;</span>
	      </a>
	    </li>
	  </c:if>
	  <c:forEach begin="1" end="${pageBean.totalPage}" var="i">
	  	  <c:if test="${pageBean.pageNo==i}">
	   	  	<li class="active"><a href="#">${i}</a></li>
	  	  </c:if>
		  <c:if test="${pageBean.pageNo!=i}">
	   		<li><a href="${pageContext.request.contextPath}/banji?method=pageList&pageNo=${i}">${i}</a></li>
		  </c:if>
	  </c:forEach>
	  <c:if test="${pageBean.pageNo==pageBean.totalPage}">  
	  	 <li class="disabled">
	      <a href="#" aria-label="Previous">
	        <span aria-hidden="true">&raquo;</span>
	      </a>
	    </li>
	  </c:if>
	  <c:if test="${pageBean.pageNo!=pageBean.totalPage}">   
	    <li>
	      <a href="${pageContext.request.contextPath}/banji?method=pageList&pageNo=${pageBean.pageNo+1}" aria-label="Previous">
	        <span aria-hidden="true">&raquo;</span>
	      </a>
	    </li>
	  </c:if>
	  </ul>
	</nav>
	<script type="text/javascript">
		function deleteById(id){
			var isDel = confirm("您确定要删除吗?");
			if(isDel){
// 				location.href="/JavaWeb190703/banji?method=deleteById&id=" + id;
				location.href="<%=request.getContextPath() %>/banji?method=deleteById&id=" + id;
			}
		}
	</script>
</body>
</html>